#
# Copyright (c) 2013 Juniper Networks, Inc. All rights reserved.
#

# -*- mode: python; -*-
import re
Import('AgentEnv')
env = AgentEnv.Clone()

# test specific modifications
AgentEnv.MakeTestEnv(env)

lib_src = ['test_xml_physical_device.cc']
env.Library('agent_physical_devices_test_xml', lib_src)

env.Append(LIBPATH = env['TOP'] + '/vnsw/agent/test-xml')
env.Append(LIBPATH = env['TOP'] + '/vnsw/agent/oper/test')
env.Append(LIBS = 'agent_test_xml')
env.Append(LIBS = 'agent_oper_test_xml')
env.Append(LIBS = 'agent_physical_devices_test_xml')

oper_test_suite = []
oper_flaky_test_suite = []

test_agent_sandesh = AgentEnv.MakeTestCmd(env, 'test_agent_sandesh', oper_test_suite)
test_config_manager = AgentEnv.MakeTestCmd(env, 'test_config_manager', oper_test_suite)
test_intf = AgentEnv.MakeTestCmd(env, 'test_intf', oper_test_suite)
test_intf_policy = AgentEnv.MakeTestCmd(env, 'test_intf_policy',
                                        oper_test_suite)
test_find_scale = AgentEnv.MakeTestCmd(env, 'test_find_scale', oper_test_suite)
test_logical_intf = AgentEnv.MakeTestCmd(env, 'test_logical_intf', oper_test_suite)
test_vrf_assign = AgentEnv.MakeTestCmd(env, 'test_vrf_assign', oper_test_suite)
test_linklocal = AgentEnv.MakeTestCmd(env, 'test_linklocal', oper_test_suite)
test_inet_interface = AgentEnv.MakeTestCmd(env, 'test_inet_interface',
                                           oper_test_suite)
test_fabric_interface = AgentEnv.MakeTestCmd(env, 'test_fabric_interface',
                                             oper_test_suite)
test_aap = AgentEnv.MakeTestCmd(env, 'test_aap', oper_test_suite)
test_aap6 = AgentEnv.MakeTestCmd(env, 'test_aap6', oper_test_suite)
test_ipv6 = AgentEnv.MakeTestCmd(env, 'test_ipv6', oper_test_suite)
test_forwarding_class = AgentEnv.MakeTestCmd(env, 'test_forwarding_class', oper_test_suite)
test_qos_config = AgentEnv.MakeTestCmd(env, 'test_qos_config', oper_test_suite)
test_health_check = AgentEnv.MakeTestCmd(env, 'test_health_check', oper_test_suite)
# test_crypt_tunnel = AgentEnv.MakeTestCmd(env, 'test_crypt_tunnel', oper_test_suite)
test_oper_xml = AgentEnv.MakeTestCmdSrc(env, 'test_oper_xml',
                                        [
                                         'test_oper_xml.cc',
                                         '../../pkt/test/test_pkt_util' + env['OBJSUFFIX'],
                                        ],
                                        oper_test_suite)
test_fip_cfg = AgentEnv.MakeTestCmd(env, 'test_fip_cfg', oper_test_suite)
test_bridge_domain = AgentEnv.MakeTestCmd(env, 'test_bridge_domain',
                                          oper_test_suite)
test_bridge_domain_mg = AgentEnv.MakeTestCmd(env, 'test_bridge_domain_mg',
                                             oper_test_suite)
test_control_word = AgentEnv.MakeTestCmd(env, 'test_control_word',
                                         oper_test_suite)
test_instance_task = AgentEnv.MakeTestCmd(env, 'test_instance_task', oper_test_suite)
test_fabric_vmi = AgentEnv.MakeTestCmd(env, 'test_fabric_vmi', oper_test_suite)
test_tsn_elector = AgentEnv.MakeTestCmd(env, 'test_tsn_elector', oper_test_suite)

env.Alias('agent:test_ipv6', test_ipv6)
test_tag = AgentEnv.MakeTestCmd(env, 'test_tag', oper_test_suite)
test_vhost_vmi = AgentEnv.MakeTestCmd(env, 'test_vhost_vmi', oper_test_suite)
test_vrouter = AgentEnv.MakeTestCmd(env, 'test_vrouter', oper_test_suite)

env.Append(LIBPATH = [
        '../../../../db/test',
        '../../../../ifmap/test',
])

env.Append(LIBS = [
        'dbtest',
        'ifmap_test_util',
        'ifmap_test_util_agent',
        'task_test',
        ])

ifmap_dependency_manager_test = env.UnitTest(
        'ifmap_dependency_manager_test',
        ['ifmap_dependency_manager_test.cc'])

env.Alias('agent:ifmap_dependency_manager_test',
          ifmap_dependency_manager_test)
oper_test_suite.append(ifmap_dependency_manager_test)

instance_manager_test = env.UnitTest(
    'instance_manager_test',
    ['instance_manager_test.cc'])
env.Alias('agent:instance_manager_test', instance_manager_test)
oper_test_suite.append(instance_manager_test)

docker_instance_adapter_test = env.UnitTest(
    'docker_instance_adapter_test',
    ['docker_instance_adapter_test.cc'])
env.Alias('agent:docker_instance_adapter_test', docker_instance_adapter_test)
oper_test_suite.append(docker_instance_adapter_test)

inet_route_tree_test = env.UnitTest(
    'inet_route_tree_test',
    ['test_inet_route_tree.cc'])
env.Alias('agent:inet_route_tree_test', inet_route_tree_test)
oper_test_suite.append(inet_route_tree_test)

libvirt_instance_adapter_test = env.UnitTest(
    'libvirt_instance_adapter_test',
    ['libvirt_instance_adapter_test.cc'])
env.Alias('agent:libvirt_instance_adapter_test', libvirt_instance_adapter_test)
# optional; requires libvirt
# oper_test_suite.append(libvirt_instance_adapter_test)

test_physical_devices = AgentEnv.MakeTestCmdSrc(env, 'test_physical_devices',
                                                [
                                                'test_physical_devices.cc',
                                                'test_xml_agent_init.cc',
                                                '../../pkt/test/test_pkt_util' + env['OBJSUFFIX'],
                                                ],
                                                oper_test_suite)

flaky_test = env.TestSuite('agent-flaky-test', oper_flaky_test_suite)
env.Alias('controller/src/vnsw/agent/oper:flaky_test', flaky_test)

test = env.TestSuite('agent-test', oper_test_suite)
env.Alias('agent:oper', test)
env.Alias('controller/src/vnsw/agent/oper:test', test)
Return('oper_test_suite')
